package com.tang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

@RestController
@RequestMapping("/auto-deliver")
public class AutoDeliverController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/checkState/{userId}")
    public Integer checkState(@PathVariable("userId") String userId) {
        String url = "http://service-resume/resume/openstate/" + userId;
        URI uri = URI.create(url);
        Integer state = restTemplate.getForObject(uri, Integer.class);
        System.out.println("调用简历微服务,获取到用户 " + userId + "的默认简历状态为:" + state);
        return state;
    }
}
